package cn.com.roy.thread.t4_1_10.lockmethodtest3;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class MyService {
    private  ReentrantLock lock = new ReentrantLock();
    private Condition condition = lock.newCondition();
    public void waitMethod(){
        try {
            lock.lock();
            condition.await();
        } catch (Exception e){

        }finally {
            lock.unlock();
        }
    }

    public void signalMethod(){
        lock.lock();
        System.out.println("有 " + lock.getWaitQueueLength(condition) + " 在等待condition");
        lock.unlock();

    }


}
